package io.wdb.wxapp.model;

import java.io.Serializable;
import java.util.Date;
import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import io.swagger.annotations.ApiModelProperty;

import io.wdb.modules.activity.wxapp.entity.HdCardAttenderEntity;
import io.wdb.modules.activity.wxapp.entity.HdUserEntity;
import io.wdb.modules.activity.wxapp.service.HdUserService;


/**
 * 抢月卡活动(支持者)
 * 
 * @author wdb
 * @email xulin@wdb007.com
 * @date 2018-01-20 15:11:02
 */
public class HdCardAttenderModel implements Serializable {
	private static final long serialVersionUID = 1L;
	
	@ApiModelProperty(value = "", required = true)
	private String id;
	@ApiModelProperty(value = "支持分数（点数）", required = true)
	private Integer score;
	@ApiModelProperty(value = "兑换money", required = true)
	private Integer money;
	@ApiModelProperty(value = "操作时间", required = true)
	private Date startTime;
	@ApiModelProperty(value = "是否到账(0未到账，1已到账)", required = true)
	private Integer account;
	@ApiModelProperty(value = "", required = true)
	private String userId;
	@ApiModelProperty(value = "", required = true)
	private String cardInitiatorId;
	
	//Nickname
	private String nickname;
	//avatar
	private String avatar;
	

	public String getNickname() {
		return nickname;
	}
	public void setNickname(String nickname) {
		this.nickname = nickname;
	}
	public String getAvatar() {
		return avatar;
	}
	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}
	/**
	 * 设置：
	 */
	public void setId(String id) {
		this.id = id;
	}
	/**
	 * 获取：
	 */
	public String getId() {
		return id;
	}
	/**
	 * 设置：支持分数（点数）
	 */
	public void setScore(Integer score) {
		this.score = score;
	}
	/**
	 * 获取：支持分数（点数）
	 */
	public Integer getScore() {
		return score;
	}
	/**
	 * 设置：兑换money
	 */
	public void setMoney(Integer money) {
		this.money = money;
	}
	/**
	 * 获取：兑换money
	 */
	public Integer getMoney() {
		return money;
	}
	/**
	 * 设置：操作时间
	 */
	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}
	/**
	 * 获取：操作时间
	 */
	public Date getStartTime() {
		return startTime;
	}
	/**
	 * 设置：是否到账(0未到账，1已到账)
	 */
	public void setAccount(Integer account) {
		this.account = account;
	}
	/**
	 * 获取：是否到账(0未到账，1已到账)
	 */
	public Integer getAccount() {
		return account;
	}
	/**
	 * 设置：
	 */
	public void setUserId(String userId) {
		this.userId = userId;
	}
	/**
	 * 获取：
	 */
	public String getUserId() {
		return userId;
	}
	/**
	 * 设置：
	 */
	public void setCardInitiatorId(String cardInitiatorId) {
		this.cardInitiatorId = cardInitiatorId;
	}
	/**
	 * 获取：
	 */
	public String getCardInitiatorId() {
		return cardInitiatorId;
	}

    public static HdCardAttenderModel convert(HdCardAttenderEntity entity,HdUserService hdUserService) {
		if(entity == null) {
			return null;
		}
		HdCardAttenderModel model = new HdCardAttenderModel();
				model.setId(entity.getId());
				model.setScore(entity.getScore());
				model.setMoney(entity.getMoney());
				model.setStartTime(entity.getStartTime());
				model.setAccount(entity.getAccount());
				model.setUserId(entity.getUserId());
				model.setCardInitiatorId(entity.getCardInitiatorId());
				
				HdUserEntity userEntity = hdUserService.queryObject(entity.getUserId());
				if(userEntity != null) {
					model.setAvatar(userEntity.getAvatar());
					model.setNickname(userEntity.getNickname());
				}
				
		return model;
	}
	public static List<HdCardAttenderModel> convert(List<HdCardAttenderEntity> entities, HdUserService hdUserService){
		if(entities == null || entities.isEmpty()) {
			return null;
		}
		List<HdCardAttenderModel> models = new ArrayList<>();
		
		for(HdCardAttenderEntity entity:entities) {
			models.add(convert(entity,hdUserService));
		}
		
		return models;
	}
	
	public static HdCardAttenderEntity convert(HdCardAttenderModel model) {
		if(model == null) {
			return null;
		}
		HdCardAttenderEntity entity = new HdCardAttenderEntity();
				entity.setId(model.getId());
				entity.setScore(model.getScore());
				entity.setMoney(model.getMoney());
				entity.setStartTime(model.getStartTime());
				entity.setAccount(model.getAccount());
				entity.setUserId(model.getUserId());
				entity.setCardInitiatorId(model.getCardInitiatorId());
				
		return entity;
	}

}
